package com.xiyoukt.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Description: springboot
 * ********************************************************
 * *                                                      *
 * *                     xiyoukt.com                      *
 * *          西游课堂 - Java程序猿的在线学习课堂          *
 * *                                                      *
 * ********************************************************
 * Created by xiyoukt on 2018/9/24 0:25
 */
@Configuration
public class Swagger2Config {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 扫描相应包路径下的所有接口，生成文档。可以在接口上添加@ApiIgnore指定不添加进文档
                .apis(RequestHandlerSelectors.basePackage("com.xiyoukt.springboot.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("SpirngBoot 整合Swagger2构建RESTful API文档")
                .contact(new Contact("xiyoukt", "http://www.xiyoukt.com",
                        "admin@xiyoukt.com"))
                .version("1.0")
                .description("API 文档")
                .build();
    }

}
